import pymysql
conn = pymysql.Connect(
    host='localhost',##mysql服务器地址
    port=3306,##mysql服务器端口号
    user='root',##用户名
    password='',##密码
    db='novel_selenium',##数据库名
    charset='utf8'##连接编码
)
# 获取游标
cursor = conn.cursor()
sql_select = "SELECT * FROM novel001" #查询所有数据
cursor.execute(sql_select)
try:
   # 执行SQL语句
   # 获取所有记录列表
   list1 = []
   for i in range(0, 15):
        results = cursor.fetchall()
        for row in results:
           a = row
           list1.append(a)
except:
   print ("Error: unable to fetch data")
conn.commit()
conn.close()
cursor.close()
